import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:ky_tool_plugin/config/ky_project_configure.dart';
import 'package:ky_tool_plugin/sizefit/ky_int_extension.dart';
import 'package:ky_tool_plugin/sizefit/ky_double_extension.dart';

class KYNormalDialog extends Dialog{

  String contentStr;
  bool backMiss;
  List <String>buttonTitlesList;
  List <Color>buttonTitlesColorsList = [KYTextBlackColor,KYNavOrangeColor];
  //0 1 2 点击返回值
  final buttonClickCallBack;
  KYNormalDialog({required this.contentStr,required this.backMiss,required this.buttonTitlesList,required this.buttonTitlesColorsList,this.buttonClickCallBack});

  dynamic _context;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    _context = context;
    double buttonWidth = (325-0.5).px/2.0;
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: (){
        if(backMiss){
          Navigator.of(context).pop();
        }
      },
      child: Material(
        type: MaterialType.transparency,
        child: Center(
          child: Container(
            width: 325.px,
            height: 200.px,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(4.px)),
            ),
            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(left: 25.px,right: 25.px),
                  height: 149.5.px,
                  alignment: Alignment.center,
                  child: Text(contentStr,style: TextStyle(fontSize: 15.px),textAlign: TextAlign.center,),
                ),
                Container(
                  height: 0.5.px,
                  color: Color(0xFFEDEDED),
                ),
                (buttonTitlesList.length == 1)?GestureDetector(
                  onTap: (){
                    buttonClickCallBack(0);
                    Navigator.of(context).pop();
                  },
                  child: Container(
                    height: 50.px,
                    color: Colors.white,
                    alignment: Alignment.center,
                    child: Text(buttonTitlesList[0],style: TextStyle(color: buttonTitlesColorsList[0],fontSize: 15.px),),
                  ),
                ):Container(
                  height: 50.px,
                  child: Row(
                    children: <Widget>[
                      GestureDetector(
                        onTap: (){
                          Navigator.of(context).pop();
                          buttonClickCallBack(0);
                        },
                        child: Container(
                          width: buttonWidth,
                          height: double.infinity,
                          color: Colors.transparent,
                          alignment: Alignment.center,
                          child: Text(buttonTitlesList[0],style: TextStyle(fontSize: 15.px,color: buttonTitlesColorsList[0]),),
                        ),
                      ),
                      Container(width: 0.5.px,color: Color(0xFFEDEDED),),
                      GestureDetector(
                        onTap: (){
                          Navigator.of(context).pop();
                          buttonClickCallBack(1);
                        },
                        child: Container(
                          width: buttonWidth,
                          height: double.infinity,
                          color: Colors.transparent,
                          alignment: Alignment.center,
                          child: Text(buttonTitlesList[1],style: TextStyle(fontSize: 15.px,color: buttonTitlesColorsList[1]),),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

}
